#include "Point3D.h"

/**************
     Point3D
 **************/
Point3D::Point3D(void)
{
}

Point3D::Point3D(double xValue, double yValue, double zValue)
  : x(xValue), y(yValue), z(zValue)
{
}

Point3D::Point3D(const Point3D &src)
{
  x = src.x;
  y = src.y;
  z = src.z;
}

void Point3D::operator = (const Point3D &right)
{
  x = right.x;
  y = right.y;
  z = right.z;
}

Point3D operator + (const Point3D &left, const Point3D &right)
{
  return Point3D(left.x + right.x, left.y + right.y, left.z + right.z);
}


Point3D operator - (const Point3D &left, const Point3D &right )
{
  return Point3D(left.x - right.x, left.y - right.y, left.z - right.z);
}

Point3D operator * (double left, const Point3D &right)
{
  return Point3D(left * right.x, left * right.y, left * right.z);
}

Point3D operator * (const Point3D &left, double right)
{
  return Point3D(left.x * right, left.y * right, left.z * right);
}

Point3D operator / (const Point3D &left, double right)
{
  return Point3D(left.x / right, left.y / right, left.z / right);
}

Point3D Point3D::Normalize3D(void)
{
  return Point3D(x / sqrt(x * x + y * y + z * z), y / sqrt(x * x + y * y + z * z), z / sqrt(x * x + y * y + z * z));
}

double Point3D::DistanceTo(const Point3D &dest) const
{
  return sqrt((dest.x - x) * (dest.x - x) + (dest.y - y) * (dest.y - y) + (dest.z - z) * (dest.z - z));
}

double Point3D::AbsoluteValue(void) const
{
  return sqrt(x * x + y * y + z * z);
}
